package com.kiln.juxingqs.ui

import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.adapter.MeCouponFragmentPageAdapter
import com.kiln.juxingqs.databinding.ActivityMecouponBinding
import com.kiln.juxingqs.ui.vm.MeCouponViewModel

class MeCouponActivity : BaseMiddleActivity<MeCouponViewModel, ActivityMecouponBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_mecoupon
    }

    override fun initViewModel(): MeCouponViewModel = createViewModel()

    val adapter: MeCouponFragmentPageAdapter by lazy {
        MeCouponFragmentPageAdapter(supportFragmentManager)
    }

    override fun initView() {
        binding?.apply {
            event = this@MeCouponActivity
            vm = viewModel
        }
        binding.viewPager.adapter = adapter
        binding.tabLayout.setupWithViewPager(binding.viewPager)

        when (intent.getIntExtra("index", 0)) {
            0 -> {
//                binding.tabWrap.getChildAt(0).isSelected = true
            }
            1 -> {
                binding.viewPager.postDelayed({
                    binding.viewPager.setCurrentItem(1, false)
                }, 10)
            }
            2 -> {
                binding.viewPager.postDelayed({
                    binding.viewPager.setCurrentItem(2, false)
                }, 10)
            }
        }
    }

}